function workUp(work_url, kid, sid, fun) {
    $.post('/work/workup', {
        work_url: work_url,
        k_id: kid,
        stu_id: sid
    }, function (data) {
        fun ? fun(data) : null;
    });
}


function fileUp (kid, sid, file, fun) {  // 上传文件
    if (file.size > 40*1024*1024) {
        alert('文件不能大于40兆！');
    } else if (file.name.endsWith('zip')) {
        var fd = new FormData();
        fd.append('work', file);
        fd.append('k_id', kid);
        fd.append('stu_id', sid);
        var $load = $('.class-down div');
        var xhr = new XMLHttpRequest();
        xhr.open('post', '/work/upload', true);
        xhr.onloadstart = function () {
            $load.removeClass('hidden');
            _can_upload = false;
        };
        xhr.onloadend = function () {
            $load.addClass('hidden');
            _can_upload = true;
        };
        xhr.onload = function () {
            var data = JSON.parse(xhr.responseText);
            if (data.status) {
                workUp(data.work_url, kid, sid, fun);
            } else {
                alert('UPFILE ERROR: ' + data.msg);
            }
        };
        xhr.send(fd);
    } else {
        alert('只支持zip格式文件');
    }
}